< previous page page_536 next page >

Page 536
EXERCISE
Setting Captions for Each Field
1. Click each field in the Command object, right-click and select the Properties menu.
2. Set the Caption property to a nice descriptive name for each field.
analysis.gif Setting the Caption property will generate nice label names if you drag and drop this command object onto a form.

Using the Connection and Command Objects at Runtime
Now that you have a Connection object and a Command object, you can use these objects in your source code. About the only things you can do with the Connection object are open it, close it, and execute a SQL INSERT, UPDATE, or DELETE statement. However, when you add a Command object, the data environment will automatically build a recordset based on that Command object. Here are two different methods for opening the Connection object thats attached to the data environment and using the Command object to fetch some data:
9f31265bb40b592b1929e18a47ab28e5.gif
Private Sub cmdTest_Click()
   denvEmployees.cnEmp.Open

   ' Do some processing
   With denvEmployees.rscmdEmployee
      .Open
      Do Until .EOF
         Debug.Print .Fields("szLast_nm")
         .MoveNext
      Loop
      .Close
   End With

   denvEmployees.cnEmp.Close
End Sub

 
< previous page page_536 next page >

If you like this book, buy it!